package com.distribution.system.manager.profitCondition;

import com.distribution.system.domain.bo.DefaultProfitConditionBO;
import com.distribution.system.manager.profitCondition.impl.DefaultProfitConditionActivation;
import com.distribution.system.manager.profitCondition.impl.DefaultProfitConditionUp100;
import com.distribution.system.manager.profitCondition.impl.DefaultProfitConditionUp50;

import java.util.Objects;

public enum DefaultProfitConditionEnum implements profitConditionInterface {
    /**
     * 默认的获利条件枚举
     */
    ACTIVATION("1", "卡激活。",new DefaultProfitConditionActivation()),
    FIRST_RECHARGE_UP_50("2", "首次冲值>=50元",new DefaultProfitConditionUp50()),
    FIRST_RECHARGE_UP_100("3", "首次冲值>=100元",new DefaultProfitConditionUp100());

    private final String code;
    private final String codeDesc;
    private final ProfitCondition<DefaultProfitConditionBO> profitCondition;
    DefaultProfitConditionEnum(String code, String codeDesc, ProfitCondition<DefaultProfitConditionBO> profitCondition) {
        this.code = code;
        this.codeDesc = codeDesc;
        this.profitCondition = profitCondition;
    }


    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getCodeDesc() {
        return codeDesc;
    }

    public ProfitCondition<DefaultProfitConditionBO> getProfitCondition() {
        return profitCondition;
    }

    public static DefaultProfitConditionEnum getEnumByCode(String code) {
        DefaultProfitConditionEnum tempDefaultProfitConditionEnum = null;
        for (int i = 0; i < DefaultProfitConditionEnum.values().length; i++) {
            DefaultProfitConditionEnum defaultProfitConditionEnum = DefaultProfitConditionEnum.values()[i];
            if (Objects.equals(defaultProfitConditionEnum.getCode(), code)) {
                tempDefaultProfitConditionEnum = defaultProfitConditionEnum;
                break;
            }
        }
        return tempDefaultProfitConditionEnum;
    }
}
